package com.jia.together.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jia.together.entity.RolePermission;
import com.jia.together.mapper.RolePermissionMapper;
import com.jia.together.service.RolePermissionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 角色权限 服务实现类
 * </p>
 *
 * @author dujiajia
 * @since 2021-02-19
 */
@Service
public class RolePermissionServiceImpl extends ServiceImpl<RolePermissionMapper, RolePermission> implements RolePermissionService {

    @Override
    public List<String> selectPermissionIdsByRoleId(String roleId) {
        QueryWrapper<RolePermission> wrapper = new QueryWrapper<>();
        wrapper.eq("role_id",roleId);
        List<RolePermission> rolePermissions = baseMapper.selectList(wrapper);
        ArrayList<String> lists = new ArrayList<>();
        rolePermissions.forEach(item->{
            lists.add(item.getPermissionId());
        });
        return lists;
    }
}
